package com.angel.infrastructure.common;


import lombok.Getter;

/*
 * 更新关注微信公众号： 为了offer
 * @author parkin
 * @description ui层统一响应对象
 * @date 2021/11/13
 */
@Getter
public final class ResultBody<T> {
    private String code;
    private T data;
    private String message;

    private ResultBody() {}

    private ResultBody(String code,T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public static final ResultBody SUCCESS = new ResultBody("200","","success");

    public static final class Empty {

    }

    public static final ResultBody SYSTEM_FAIL = new ResultBody("500","","system error");

    public static<T> ResultBody<T> success(T data) {
        return success(data,"success");
    }

    public static<T> ResultBody<T> success(T data,String message) {
        return new ResultBody<>(SUCCESS.code, data,message);
    }

}
